package service;

import dao.UsersManager;
import model.User;
import java.util.Objects;

public interface AccountService {

    LoginState verificate(String username, String password);

    LoginState verificate(Long uid, String password);

    UsersManager.UserDAOOptionResult register(String userName, String userPassword, String userNickname);

    LoginInfo login(String uname, String upass);


    enum LoginState {FAIL, ACCOUNTDISABLED, ACCOUNTBANNED, EXCEPTION, SUCCEED};
    //enum AccountState {DISABLED, BANNED, ENABLED};

    class LoginInfo {

        private LoginState loginState;
        private User       userInfo;
        private Long       userQQ;
        private String     userWechat;

        public LoginInfo(LoginState loginState, User userInfo, Long userQQ, String userWechat) {
            this.loginState = loginState;
            this.userInfo = userInfo;
            this.userQQ = userQQ;
            this.userWechat = userWechat;
        }

        public Long getUserQQ() {
            return userQQ;
        }

        public void setUserQQ(Long userQQ) {
            this.userQQ = userQQ;
        }

        public String getUserWechat() {
            return userWechat;
        }

        public void setUserWechat(String userWechat) {
            this.userWechat = userWechat;
        }

        public LoginState getLoginState() {
            return loginState;
        }

        public void setLoginState(LoginState loginState) {
            this.loginState = loginState;
        }

        public User getUserInfo() {
            return userInfo;
        }

        public void setUserInfo(User userInfo) {
            this.userInfo = userInfo;
        }

        @Override
        public String toString() {
            return "LoginInfo{" +
                    "loginState=" + loginState +
                    ", userInfo=" + userInfo +
                    ", userQQ=" + userQQ +
                    ", userWechat='" + userWechat + '\'' +
                    '}';
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            LoginInfo loginInfo = (LoginInfo) o;
            return loginState == loginInfo.loginState &&
                    Objects.equals(userInfo, loginInfo.userInfo);
        }

        @Override
        public int hashCode() {
            return Objects.hash(loginState, userInfo);
        }
    }

}
